﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Web.Core;
using Web.Core.Objects;

public partial class include_content : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.product_list.DataSource = Categories.GetTop((int)Session["Language"]);
        this.product_list.DataBind();
    }

    public string getProductByCategory(int catID)
    {
        ArrayList _products = new ArrayList();
        _products = Products.GetAllProductsByCategoryIDVisible((int)Session["Language"], catID, 1, 3);
        string str = "";
        foreach (Product item in _products)
        {
            str +="<li><span style='font-weight: bold;'>"+item.Name;
            str += "</span><div class='vmProductSnapshot'><a href='?act=product&id="+item.ProductID+"' title='" + item.Name + "'>";
            str += "<img border='0' alt='" + item.Name + "' src='images/products/"+item.Image+"' style='width: 110px; height: 140px;'>";
            str +="</a> </div><span class='productPrice'>$"+item.Price+"</span> <br></li>";
        }
        return str;                                              
    }
    public string paging(int catID)
    {
        int total = Products.CountAllProductsByCategoryIDVisible((int)Session["Language"], catID);
        int pages = (int)(total / 3);
        if ((total % 3) > 0)
            pages ++;
        if (pages > 1)
        {
            string str = "<a class='prev' href='#prev' onclick='previousPage(" + catID + ")'>Previous</a> ";
            for (int i = 1; i <= pages; i++)
            {
                str += "<a class='toc' href='javascript:loadProduct(" + catID + "," + i + ");' rel='" + i + "'>" + i + "</a> ";
            }
            str += "<a class='next'  href='#next' onclick='nextPage(" + catID + ")'>Next</a>";
            return str;
        }
        else
            return null;
    }
}
